const uname = JSON.parse(localStorage.getItem('nowLogin'))
const infoName = document.querySelector('.info_name')
if (uname) {
    infoName.innerHTML = uname
} else {
    infoName.innerHTML = '请登录'
    infoName.addEventListener('click', function() {
        location.href = './login.html'
    })
}

// 早中晚打招呼
let getTimeState = () => {
    // 获取当前时间
    let timeNow = new Date();
    // 获取当前小时
    let hours = timeNow.getHours();
    // 设置默认文字
    let text = ``;
    // 判断当前时间段
    if (hours >= 0 && hours <= 10) {
        text = `早上好`;
    } else if (hours > 10 && hours <= 14) {
        text = `中午好`;
    } else if (hours > 14 && hours <= 18) {
        text = `下午好`;
    } else if (hours > 18 && hours <= 24) {
        text = `晚上好`;
    }
    // 返回当前时间段对应的状态
    return text;
}
const greet = document.querySelector('.greet')
greet.innerHTML = getTimeState()

const finshNum = document.querySelector('.finshNum')
const finshWeek = document.querySelector('.finshWeek')
const num = JSON.parse(localStorage.getItem('lineArr'))

finshNum.innerHTML = num
finshWeek.innerHTML = num
    // 退出登录
const quit = document.querySelector('.quit')
quit.addEventListener('click', function() {
    localStorage.removeItem('nowLogin')
    location.href = './login.html'
})